﻿@{
    Layout = "~/_SiteLayout.cshtml";
    Page.Title = "Disassociate OAuth accounts";

    WebSecurity.RequireAuthenticatedUser();
    ICollection<OAuthAccount> accounts = null;

    if (IsPost) {
        string provider = Request.Form["provider"];
        string providerUserId = Request.Form["providerUserId"];
        OAuthWebSecurity.DeleteAccount(provider, providerUserId);
    }

    string username = WebSecurity.CurrentUserName;
    accounts = OAuthWebSecurity.GetAccountsFromUserName(username);
}

<hgroup class="title">
    <h1>@Page.Title.</h1>
    <h2>Choose a service to disassociate with this account.</h2>
</hgroup>

@if (accounts != null && accounts.Count > 0) {
    <fieldset>
        <legend>Choose a service to disassociate with this account</legend>
        @foreach (var service in accounts) {
            <form method="post">
                <input type="hidden" name="providerUserId" value="@service.ProviderUserId" />
                <input type="submit" name="provider" id="@service.Provider" value="@service.Provider" title="Disassociate @(service.Provider + " - " + service.ProviderUserId) from this account." />
            </form>
        }
    </fieldset>
} else {
    <div class="message-info">
        <p>This account is not associated with any additional services.</p>
    </div>
}